Skip to content

Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 1 | Structuring and Testing Data#1073

Open
Richiealx wants to merge 17 commits intoCodeYourFuture:mainfrom
Richiealx:coursework/sprint-1
Open

Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 1 | Structuring and Testing Data#1073
Richiealx wants to merge 17 commits intoCodeYourFuture:mainfrom
Richiealx:coursework/sprint-1

Conversation

@Richiealx
Copy link

@Richiealx Richiealx commented Feb 26, 2026

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Completed Sprint 1 coursework:

  • Key exercises completed
  • Mandatory errors analysed and explained in answers.md
  • Mandatory interpret section completed
  • Stretch exploration completed
  • Learning log updated

Thanks for the feedback @cjyuan!

Answers to follow-up questions

Programming term for count = count + 1

The one-word programming term is increment.
The statement increases the value stored in the variable by 1 and assigns the updated value back to the same variable.
This pattern is very common and can also be written using shorthand operators such as count += 1; or count++;.

Is .padEnd(2, "0") necessary?

Yes, .padEnd(2, "0") is needed to handle cases where the pence value has fewer than two digits.

For example:

  • If penceString = "5p", removing "p" gives "5"
  • substring(length - 2) would return "5" (only one digit)

Without .padEnd(2, "0"), the output would be £0.5.
With .padEnd(2, "0"), it becomes £0.50.

So .padEnd ensures the pence part always contains exactly two digits, which is required for correct currency formatting.

@Richiealx Richiealx added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 26, 2026
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clear explanation and answers! I just have two follow-up questions.

Comment on lines +10 to +11
// Line 3 takes the current value of count (0), adds 1 to it,
// and assigns the result (1) back to the count variable using =. No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Operation like count = count + 1 is very common in programming, and there is a programming term describing such operation.

Can you find out what one-word programming term describes the operation on line 3?

Comment on lines +141 to +145
5) `const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");`
- First, `substring(length - 2)` takes the last 2 digits.
- Then `padEnd(2, "0")` ensures it’s at least 2 characters (adds zeros on the right if needed).
- Purpose: get exactly two pence digits.
- For `"399"`, last two digits are `"99"` → stays `"99"`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we expect this program to work as intended for any valid penceString if we deleted .padEnd(2, "0") from the code?
In other words, do we really need .padEnd(2, "0") in this script?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants